#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
void sigint_handler(int signo)
{
    if (signo == SIGINT)
    {
        printf("收到停止信号(%d),停止进程\n", signo);
        exit(EXIT_FAILURE);
    }
    else if (signo == SIGTERM)
    {
        printf("收到终止信号(%d),终止进程\n", signo);
        exit(EXIT_FAILURE);
    }
}
int main(int argc, char const *argv[])
{
    if (signal(SIGINT, sigint_handler) == SIG_ERR)
    {
        perror("SIGINT 注册失败");
        exit(1);
    }
    if (signal(SIGTERM, sigint_handler) == SIG_ERR)
    {
        perror("SIGTERM 注册失败");
        exit(1);
    }
    while (1)
    {
        printf("等待信号\n");
        sleep(1);
    }
    return 0;
}
